package smartcampus.scjava.controller.forth;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import smartcampus.scjava.POJO.DO.BookBorrow;
import smartcampus.scjava.POJO.DO.LibrarySeat;
import smartcampus.scjava.custom.ResultVO;
import smartcampus.scjava.service.ILibrarySeatService;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 图书馆座位表 前端控制器
 * </p>
 *
 * @author xian
 * @since 2023-11-22
 */
@RestController
@RequestMapping("/library-seat")
public class LibrarySeatController {



    @Resource
    private ILibrarySeatService seatService;


    @RequestMapping("/listPage")
    public ResultVO<?> listPage(Integer  pageNum,Integer pageSize, String word) {
        if (pageNum == null || pageSize == null) {
            return ResultVO.error("分页参数错误");
        }

        QueryWrapper<LibrarySeat> query = new QueryWrapper<>();
        if (StringUtils.hasText(word)) {
            query.lambda().like(LibrarySeat::getSeatNo,word).or().like(LibrarySeat::getLocation,word);
        }
        Page<LibrarySeat> page = new Page<>(pageNum,pageSize);
        seatService.page(page,query);

        return ResultVO.success(page);
    }




}
